﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Cryomancer.WPF.CustomControls">
	<SolidColorBrush x:Key="MasterBackgroundBrush" Color="#FF516E51" />
	<SolidColorBrush x:Key="ControlBackgroundBrush" Color="#FF305030" />
	<SolidColorBrush x:Key="MutedFontBrush" Color="#FFc9c9c9" />


	<Style x:Key="TabItemFocusVisual">
		<Setter Property="Control.Template">
			<Setter.Value>
				<ControlTemplate>
					<Rectangle SnapsToDevicePixels="true" Margin="3,3,3,1" Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1"/>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<SolidColorBrush x:Key="TabControlNormalBorderBrush" Color="#919B9C"/>
	<LinearGradientBrush x:Key="TabItemNormalBackground" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="#FFFFFFFF" Offset="0"/>
		<GradientStop Color="#FFECEBE6" Offset="1"/>
	</LinearGradientBrush>
	<SolidColorBrush x:Key="TabItemHotBorderBrush" Color="#FFE68B2C"/>
	<SolidColorBrush x:Key="TabItemHotBorderBackround" Color="#FFFFC73C"/>
	<LinearGradientBrush x:Key="TabItemHotBackground" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="#FFFFFFFF" Offset="0"/>
		<GradientStop Color="#FFECEBE6" Offset="1"/>
	</LinearGradientBrush>
	<SolidColorBrush x:Key="TabItemSelectedBorderBrush" Color="#FFE68B2C"/>
	<SolidColorBrush x:Key="TabItemSelectedBorderBackround" Color="#FFFFC73C"/>
	<SolidColorBrush x:Key="TabItemSelectedBackground" Color="#FFFCFCFE"/>
	<SolidColorBrush x:Key="TabItemDisabledBackground" Color="#FFF5F4EA"/>
	<SolidColorBrush x:Key="TabItemDisabledBorderBrush" Color="#FFC9C7BA"/>
	<Style x:Key="TabItemClosableButtonStyle" TargetType="{x:Type Button}">
		<Setter Property="FocusVisualStyle" Value="{x:Null}" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Button}">
					<Border x:Name="ButtonBorder" BorderThickness="1,1,1,1">
						<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="Center" VerticalAlignment="Center" />
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter Property="BorderBrush" TargetName="ButtonBorder" Value="#FF053AF4"/>
							<Setter Property="Background" TargetName="ButtonBorder" Value="#FFB1C2FB"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<Style TargetType="{x:Type local:TabItemClosable}">
		<Setter Property="FocusVisualStyle" Value="{StaticResource TabItemFocusVisual}"/>
		<Setter Property="Padding" Value="6,2,6,2"/>
		<Setter Property="BorderThickness" Value="1,1,1,0"/>
		<Setter Property="BorderBrush" Value="{StaticResource TabControlNormalBorderBrush}"/>
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="Background" Value="{StaticResource TabItemNormalBackground}"/>
		<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
		<Setter Property="VerticalContentAlignment" Value="Stretch"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:TabItemClosable}">
					<Border SnapsToDevicePixels="true">
						<Grid Margin="0,0,1,0">
							<Grid x:Name="Transform">
								<Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3,3,0,0"/>
								<Border x:Name="HighlightBorder" VerticalAlignment="Top" Height="3" BorderThickness="1,1,1,0" CornerRadius="3,3,0,0"/>
							</Grid>
							<DockPanel HorizontalAlignment="Center" VerticalAlignment="Center">
								<Button DockPanel.Dock="Right" Width="16" Height="16" Style="{StaticResource TabItemClosableButtonStyle}" x:Name="Part_CloseButton" >
									<Path x:Name="CloseButtonPath" Stretch="Fill" StrokeThickness="0.5" Stroke="Black" Fill="Gray" Data="F1 M 2.28484e-007,1.33331L 1.33333,0L 4.00001,2.66669L 6.66667,6.10352e-005L 8,1.33331L 5.33334,4L 8,6.66669L 6.66667,8L 4,5.33331L 1.33333,8L 1.086e-007,6.66669L 2.66667,4L 2.28484e-007,1.33331 Z " Width="10" Height="10" HorizontalAlignment="Center" VerticalAlignment="Center"/>
								</Button>
								<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header" RecognizesAccessKey="True"  HorizontalAlignment="Center" VerticalAlignment="Center" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Margin="{TemplateBinding Padding}"/>
							</DockPanel>
						</Grid>
					</Border>

					<ControlTemplate.Triggers>
						<Trigger Property="IsSelected" Value="true">
							<Setter Property="Panel.ZIndex" Value="1"/>
						</Trigger>
						<Trigger Property="TabStripPlacement" Value="Bottom"/>
						<Trigger Property="TabStripPlacement" Value="Left"/>
						<Trigger Property="TabStripPlacement" Value="Right"/>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
						</Trigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsSelected" Value="true"/>
								<Condition Property="TabStripPlacement" Value="Top"/>
							</MultiTrigger.Conditions>
							<Setter Property="Margin" Value="-2,-2,-2,-1"/>
							<Setter Property="FontWeight" Value="Bold" />
						</MultiTrigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsSelected" Value="true"/>
								<Condition Property="TabStripPlacement" Value="Bottom"/>
							</MultiTrigger.Conditions>
							<Setter Property="Margin" Value="-2"/>
						</MultiTrigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsSelected" Value="true"/>
								<Condition Property="TabStripPlacement" Value="Left"/>
							</MultiTrigger.Conditions>
							<Setter Property="Margin" Value="-2,-2,-1,-2"/>
						</MultiTrigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsSelected" Value="true"/>
								<Condition Property="TabStripPlacement" Value="Right"/>
							</MultiTrigger.Conditions>
							<Setter Property="Margin" Value="-1,-2,-2,-2"/>
						</MultiTrigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<LinearGradientBrush x:Key="TabControlPaneTopNormalBackground" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="#FFFCFCFE" Offset="0"/>
		<GradientStop Color="#FFF4F3EE" Offset="1"/>
	</LinearGradientBrush>
	<LinearGradientBrush x:Key="TabControlPaneBottomNormalBackground" EndPoint="0,0" StartPoint="0,1">
		<GradientStop Color="#FFFCFCFE" Offset="0"/>
		<GradientStop Color="#FFF4F3EE" Offset="1"/>
	</LinearGradientBrush>
	<LinearGradientBrush x:Key="TabControlPaneLeftNormalBackground" EndPoint="1,0" StartPoint="0,0">
		<GradientStop Color="#FFFCFCFE" Offset="0"/>
		<GradientStop Color="#FFF4F3EE" Offset="1"/>
	</LinearGradientBrush>
	<LinearGradientBrush x:Key="TabControlPaneRightNormalBackground" EndPoint="0,0" StartPoint="1,0">
		<GradientStop Color="#FFFCFCFE" Offset="0"/>
		<GradientStop Color="#FFF4F3EE" Offset="1"/>
	</LinearGradientBrush>

	<Style x:Key="TabControlAddableButtonStyle" TargetType="{x:Type Button}">
		<Setter Property="FocusVisualStyle" Value="{x:Null}" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Button}">
					<Border x:Name="ButtonBorder" BorderThickness="1,1,1,1">
						<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="Center" VerticalAlignment="Center" />
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter Property="BorderBrush" TargetName="ButtonBorder" Value="#FF053AF4"/>
							<Setter Property="Background" TargetName="ButtonBorder" Value="#FFB1C2FB"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style TargetType="{x:Type local:TabControlAddable}">
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="Padding" Value="4,4,4,4"/>
		<Setter Property="BorderThickness" Value="1"/>
		<Setter Property="BorderBrush" Value="{StaticResource TabControlNormalBorderBrush}"/>
		<Setter Property="Background" Value="{StaticResource TabControlPaneTopNormalBackground}"/>
		<Setter Property="HorizontalContentAlignment" Value="Center"/>
		<Setter Property="VerticalContentAlignment" Value="Center"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:TabControlAddable}">
					<Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
						<Grid.ColumnDefinitions>
							<ColumnDefinition x:Name="ColumnDefinition0"/>
							<ColumnDefinition Width="0" x:Name="ColumnDefinition1"/>
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
							<RowDefinition x:Name="RowDefinition1" Height="*"/>
						</Grid.RowDefinitions>
						<DockPanel Margin="2,2,2,-2">
							<TabPanel x:Name="HeaderPanel"  Height="18.2766666666667" IsItemsHost="true" Panel.ZIndex="1" KeyboardNavigation.TabIndex="1"/>
							<DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
								<Button x:Name="Part_AddButton" Width="16" Height="16" Style="{DynamicResource TabControlAddableButtonStyle}" VerticalAlignment="Top" DockPanel.Dock="Left" HorizontalAlignment="Left" Margin="5,0,0,0">
									<Path x:Name="CloseButtonPath" Stretch="Fill" StrokeThickness="0.5" Stroke="Black" Fill="Gray" Data="F1 M 2.28484e-007,1.33331L 1.33333,0L 4.00001,2.66669L 6.66667,6.10352e-005L 8,1.33331L 5.33334,4L 8,6.66669L 6.66667,8L 4,5.33331L 1.33333,8L 1.086e-007,6.66669L 2.66667,4L 2.28484e-007,1.33331 Z " Width="10" Height="10" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" Margin="0,0,0,0">
										<Path.RenderTransform>
											<TransformGroup>
												<ScaleTransform ScaleX="1" ScaleY="1"/>
												<SkewTransform AngleX="0" AngleY="0"/>
												<RotateTransform Angle="45"/>
												<TranslateTransform X="0" Y="0"/>
											</TransformGroup>
										</Path.RenderTransform>
									</Path>
								</Button>
							</DockPanel>
						</DockPanel>
						<Border x:Name="ContentPanel" BorderBrush="#D0CEBF" BorderThickness="0,0,1,1" Grid.Column="0" Grid.Row="1" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
							<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
								<Border Background="{TemplateBinding Background}">
									<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" x:Name="PART_SelectedContentHost" ContentSource="SelectedContent"/>
								</Border>
							</Border>
						</Border>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="TabStripPlacement" Value="Bottom">
							<Setter Property="Grid.Row" TargetName="HeaderPanel" Value="1"/>
							<Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
							<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
							<Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
							<Setter Property="Margin" TargetName="HeaderPanel" Value="2,0,2,2"/>
							<Setter Property="Background" Value="{StaticResource TabControlPaneBottomNormalBackground}"/>
						</Trigger>
						<Trigger Property="TabStripPlacement" Value="Left">
							<Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
							<Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
							<Setter Property="Grid.Column" TargetName="HeaderPanel" Value="0"/>
							<Setter Property="Grid.Column" TargetName="ContentPanel" Value="1"/>
							<Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
							<Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
							<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
							<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
							<Setter Property="Margin" TargetName="HeaderPanel" Value="2,2,-1,2"/>
							<Setter Property="Background" Value="{StaticResource TabControlPaneLeftNormalBackground}"/>
						</Trigger>
						<Trigger Property="TabStripPlacement" Value="Right">
							<Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
							<Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
							<Setter Property="Grid.Column" TargetName="HeaderPanel" Value="1"/>
							<Setter Property="Grid.Column" TargetName="ContentPanel" Value="0"/>
							<Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
							<Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
							<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
							<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
							<Setter Property="Margin" TargetName="HeaderPanel" Value="-1,2,2,2"/>
							<Setter Property="Background" Value="{StaticResource TabControlPaneRightNormalBackground}"/>
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>
